Today most videos are shown by plug-ins like flash or Silverlight but all browsers did not support same plug-ins. HTML5 specifies a standard way to support video using video element. The formats which are supported by video elements are Ogg, MPEG4 or WebM.
- Ogg = Ogg files with theora video codec and vorbis audio codec.
- MPEG4=MPEG4 files with H.264 video codec and AAC audio codec.
- WebM=WebM files with VP8 video codec and vorbis audio codec.
Syntax
<video src=”file name with location” controls=”controls to be used”></video>
Video attributes:
- src: In this attribute we have to pass the source of movie clip.
- Width: In this attribute we can pass width of video.
- Loop: If video has finished it will start again.
- Height: Set the height of the video.
- Poster: Video image that specifies the video.
- Autoplay: Specifies whether or not to start playing the video as soon as it can do so without stopping.
- Preload: Specifies video should be preloaded or not.
- Controls: Specifies control button display(play, pause or stop button etc).
Following sample represent use of video element in html5
<!DOCTYPE HTML>
<html>
<body>
<video width="600" height="300" controls="controls">
<source src="Video/sample.mp4" type="video/mp4" />
</video>
</body>
</html>
Output of following code snippet is as follows
Note: This code snippet is supported by Google Chrome and Mozilla Firefox4
Leave Comment